<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../layui/css/layui.css"/>
	</head>
	<body style="padding: 30px 10px 10px 10px">
	<form class="layui-form" lay-filter="chanceDataFilter">
			<input type="hidden" name="chNo" />
			<div class="layui-form-item">
				<label class="layui-form-label">创建人</label>
				<div class="layui-input-inline" style="width: 30%;">
					<input type="text" name="chCreator"  lay-verify="required" autocomplete="off" placeholder="不可修改!" disabled class="layui-input layui-disabled" />
				</div>
				<label class="layui-form-label">创建时间</label>
				<div class="layui-input-inline" style="width: 30%;">
					<input type="text" name="chCreationdate" lay-verify="required|date" id='creationDate' autocomplete="off" placeholder="不可修改!" disabled class="layui-input layui-disabled" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">任务接收者<i style="color: red;"> * </i></label>
				<div class="layui-input-inline" style="width: 30%;">
					<input type="text" name="chRole" placeholder="请输入任务接收者!" class="layui-input " />
					
				</div>
				<label class="layui-form-label">指派时间<i style="color: red;"> * </i></label>
				<div class="layui-input-inline" style="width: 30%;">					
					<input type="text" name="chAssigindate" lay-verify="required|date" id="assiginDate" autocomplete="off" placeholder="不可修改!" disabled class="layui-input layui-disabled" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">客户名称</label>
				<div class="layui-input-inline" style="width: 30%;">
					<input type="text" name="chName"  lay-verify="required" autocomplete="off" placeholder="请输入客户名称!" disabled class="layui-input layui-disabled"/>
					
					
				</div>
				<label class="layui-form-label">联系人</label>
				<div class="layui-input-inline" style="width: 30%;">
					<input type="text" name="chContacts" lay-verify="required" lay-reqtext="不能为空!" autocomplete="off" placeholder="请输入联系人!" disabled class="layui-input layui-disabled"/>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">客户电话</label>
				<div class="layui-input-inline" style="width: 30%;">
					<input type="text" name="chPhone"  lay-verify="required|phone|number" autocomplete="off" placeholder="请输入联系电话!" disabled class="layui-input layui-disabled" />
				</div>
			   <label class="layui-form-label">销售机会状态</label>
			     <div class="layui-input-inline" style="width: 30%;">
			     	<!-- <input type="text" value="1" placeholder="正在指派!" lay-verify="required" disabled class="layui-input layui-disabled" /> -->
					<select name="chState"lay-verify="required">
						<option value="1" selected >正在指派</option>
					</select>
			     </div>
			</div>
			<div class='layui-form-item'>
				<label class="layui-form-label">概要描述</label>
				<div class="layui-input-inline" style="width: 60%;">
					<!-- <input type="text" name="chDescribed" autocomplete="off" placeholder="请输入概要描述!" class="layui-input"/> -->
					<textarea placeholder="请输入概要描述!" disabled class="layui-disabled layui-textarea" name="chDescribed"></textarea>
				</div>
			</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="submit" class="layui-btn" lay-submit lay-filter="submitUpdateChance"> 提交</button>
				<button type="reset" class="layui-btn layui-btn-primary"> 重置</button>
			</div>
		</div>
		
	</form>	



		<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			layui.use(['form','jquery','laydate'], function(){
				var form = layui.form;
				var $ = layui.jquery;
				var laydate = layui.laydate;
				// laydate.render({
				// 	elem:'#assiginDate'
				// });
				// console.log(parent.rowSale)
				// debugger
				// var $ = layui.jquery
				//formUpdateCustomer时form的lay-filter属性
				 //填写数据到弹窗（3-3）将全局变量rowSale写进表单
				form.val('chanceDataFilter', {
				      "chNo": parent.rowSale.chNo // "name": "value"
				      ,"chName": parent.rowSale.chName
				      ,"chContacts": parent.rowSale.chContacts
				      ,"chPhone": parent.rowSale.chPhone
					  ,"chDescribed":parent.rowSale.chDescribed
					  ,"chCreator":parent.rowSale.chCreator
					  ,"chCreationdate":parent.rowSale.chCreationdate

				    });
					
			//监听提交// lay-submit="" lay-filter="submitUpdateCustomer"
			  form.on('submit(submitUpdateChance)', function(d){
				  d.field
				  if(form.verify()){//校验
					  $.ajax({//异步提交不排队eg.未完成就刷新，ajax中断
					  	url:'http://localhost:8080/chance/updateChance',
					  	type:'POST',
					  	dataType:'JSON',
					  	data:d.field,//js对象是JSON
					  	success:function(obj){//异步，必须使用回调函数
					  		//执行ajax成功后的代码
					  		parent.table.reload('salesManage')
					  		//当你在iframe页面关闭自身时
					  		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					  		parent.layer.close(index); //再执行关闭  
					  		// 刷新表格
					  		
					  	},
					  })
				  }
				// data.field//表单的数据
				
				return false;//阻止form提交刷新
			  })
				 	
			Date.prototype.format = function (format) {
			           var args = {
			               "M+": this.getMonth() + 1,
			               "d+": this.getDate(),
			               "h+": this.getHours(),
			               "m+": this.getMinutes(),
			               "s+": this.getSeconds(),
			               "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
			               "S": this.getMilliseconds()
			           };
			           if (/(y+)/.test(format))
			               format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
			           for (var i in args) {
			               var n = args[i];
			               if (new RegExp("(" + i + ")").test(format))
			                   format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length));
			           }
			           return format;
			       };
			
			$("#assiginDate").val(new Date().format("yyyy-MM-dd"))
			})
		</script>
	</body>
</html>
